package com.genexususa.eo.bing.test.add;

import com.genexususa.eo.bing.connection.AdManager;
import com.genexususa.eo.bing.test.TestUtil;

public class ConsumeAddAds {
    public static void main(String[] args) {
        TestUtil testUtil = new TestUtil();
        String adsRequestsXML = "<Bing_AdsRequestCollection xmlns=\"L2TMediaDev\">\n" +
                                    "\t<Bing_AdsRequest xmlns=\"L2TMediaDev\">\n" +
                                        "\t\t<GxCampaignId>45616011</GxCampaignId>\n" +
                                        "\t\t<BingCampaignId>" + testUtil.campaignId1 + "</BingCampaignId>\n" +
                                        "\t\t<AdsAdGroupRequestCollection>\n" +
                                            "\t\t\t<AdsAdGroupRequest>\n" +
                                                "\t\t\t\t<GxAdGroupId>452315612</GxAdGroupId>\n" +
                                                "\t\t\t\t<BingAdGroupId>" + testUtil.adGroup11 + "</BingAdGroupId>\n" +
                                                "\t\t\t\t<AdCollection>\n" +
                                                    "\t\t\t\t\t<MobileAdCollection>\n" +
                                                        "\t\t\t\t\t\t<MobileAd>\n" +
                                                            "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                                                            "\t\t\t\t\t\t\t<GxMobileAdId>1234567891</GxMobileAdId>\n" +
                                                            "\t\t\t\t\t\t\t<Status/>\n" +
                                                            "\t\t\t\t\t\t\t<Type/>\n" +
                                                            "\t\t\t\t\t\t\t<BusinessName>Nombre del business</BusinessName>\n" +
                                                            "\t\t\t\t\t\t\t<DestinationUrl/>\n" +
                                                            "\t\t\t\t\t\t\t<DisplayUrl/>\n" +
                                                            "\t\t\t\t\t\t\t<PhoneNumber>12345678</PhoneNumber>\n" +
                                                            "\t\t\t\t\t\t\t<Text>Texto111</Text>\n" +
                                                            "\t\t\t\t\t\t\t<Title>Titulo del ad111</Title>\n" +
                                                        "\t\t\t\t\t\t</MobileAd>\n" +
                                                    "\t\t\t\t\t</MobileAdCollection>\n" +
                                                    "\t\t\t\t\t<TextAdCollection>\n" +
                                                        "\t\t\t\t\t\t<TextAd>\n" +
                                                            "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                                                            "\t\t\t\t\t\t\t<GxTextAdId>1234567892</GxTextAdId>\n" +
                                                            "\t\t\t\t\t\t\t<Status/>\n" +
                                                            "\t\t\t\t\t\t\t<Type>Text</Type>\n" +
                                                            "\t\t\t\t\t\t\t<DestinationUrl>www.textdestination.com</DestinationUrl>\n" +
                                                            "\t\t\t\t\t\t\t<DisplayUrl>www.textdisplay.com</DisplayUrl>\n" +
                                                            "\t\t\t\t\t\t\t<Text>Texto112</Text>\n" +
                                                            "\t\t\t\t\t\t\t<Title>Titulo del ad112</Title>\n" +
                                                        "\t\t\t\t\t\t</TextAd>\n" +
                                                    "\t\t\t\t\t</TextAdCollection>\n" +
                                                "\t\t\t\t</AdCollection>\n" +
                                            "\t\t\t</AdsAdGroupRequest>\n" +
                                        "\t\t</AdsAdGroupRequestCollection>\n" +
                                    "\t</Bing_AdsRequest>\n" +
                                    "\t<Bing_AdsRequest xmlns=\"L2TMediaDev\">\n" +
                                        "\t\t<GxCampaignId>45616012</GxCampaignId>\n" +
                                        "\t\t<BingCampaignId>" + testUtil.campaignId1 + "</BingCampaignId>\n" +
                                        "\t\t<AdsAdGroupRequestCollection>\n" +
                                            "\t\t\t<AdsAdGroupRequest>\n" +
                                                "\t\t\t\t<GxAdGroupId>452315613</GxAdGroupId>\n" +
                                                "\t\t\t\t<BingAdGroupId>" + testUtil.adGroup12 + "</BingAdGroupId>\n" +
                                                "\t\t\t\t<AdCollection>\n" +
                                                    "\t\t\t\t\t<MobileAdCollection>\n" +
                                                    "\t\t\t\t\t\t<MobileAd>\n" +
                                                        "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                                                            "\t\t\t\t\t\t\t<GxMobileAdId>1234567893</GxMobileAdId>\n" +
                                                            "\t\t\t\t\t\t\t<Status/>\n" +
                                                            "\t\t\t\t\t\t\t<Type>Mobile</Type>\n" +
                                                            "\t\t\t\t\t\t\t<BusinessName>Otro business</BusinessName>\n" +
                                                            "\t\t\t\t\t\t\t<DestinationUrl>www.mobiledest2.com</DestinationUrl>\n" +
                                                            "\t\t\t\t\t\t\t<DisplayUrl>www.mobiledisp2.com</DisplayUrl>\n" +
                                                            "\t\t\t\t\t\t\t<PhoneNumber/>\n" +
                                                            "\t\t\t\t\t\t\t<Text>Texto211</Text>\n" +
                                                            "\t\t\t\t\t\t\t<Title>Titulo del ad211</Title>\n" +
                                                        "\t\t\t\t\t\t</MobileAd>\n" +
                                                    "\t\t\t\t\t</MobileAdCollection>\n" +
                                                    "\t\t\t\t\t<TextAdCollection>\n" +
                                                        "\t\t\t\t\t\t<TextAd>\n" +
                                                            "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                                                            "\t\t\t\t\t\t\t<GxTextAdId>1234567894</GxTextAdId>\n" +
                                                            "\t\t\t\t\t\t\t<Status/>\n" +
                                                            "\t\t\t\t\t\t\t<Type/>\n" +
                                                            "\t\t\t\t\t\t\t<DestinationUrl>www.hello.com</DestinationUrl>\n" +
                                                            "\t\t\t\t\t\t\t<DisplayUrl>www.textdisplay2.com</DisplayUrl>\n" +
                                                            "\t\t\t\t\t\t\t<Text>Texto221</Text>\n" +
                                                            "\t\t\t\t\t\t\t<Title>Titulo del ad221</Title>\n" +
                                                        "\t\t\t\t\t\t</TextAd>\n" +
                                                    "\t\t\t\t\t</TextAdCollection>\n" +
                                                "\t\t\t\t</AdCollection>\n" +
                                            "\t\t\t</AdsAdGroupRequest>\n" +
                                        "\t\t</AdsAdGroupRequestCollection>\n" +
                                    "\t</Bing_AdsRequest>\n" +
                                "</Bing_AdsRequestCollection>\n";

        adsRequestsXML = "<Bing_AdsRequestCollection xmlns=\"L2TMediaDev_L2T1.51\">\n" +
                "\t<Bing_AdsRequest xmlns=\"L2TMediaDev_L2T1.51\">\n" +
                "\t\t<GxCampaignId>699</GxCampaignId>\n" +
                "\t\t<BingCampaignId>1951372664</BingCampaignId>\n" +
                "\t\t<AdsAdGroupRequestCollection>\n" +
                "\t\t\t<AdsAdGroupRequest>\n" +
                "\t\t\t\t<GxAdGroupId>2262</GxAdGroupId>\n" +
                "\t\t\t\t<BingAdGroupId>2468100780</BingAdGroupId>\n" +
                "\t\t\t\t<AdCollection>\n" +
                "\t\t\t\t\t<TextAdCollection>\n" +
                "\t\t\t\t\t\t<TextAd>\n" +
                "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                "\t\t\t\t\t\t\t<GxTextAdId>15666</GxTextAdId>\n" +
                "\t\t\t\t\t\t\t<BingTextAdId>0</BingTextAdId>\n" +
                "\t\t\t\t\t\t\t<Status>E</Status>\n" +
                "\t\t\t\t\t\t\t<Type>Text</Type>\n" +
                "\t\t\t\t\t\t\t<DestinationUrl>?)(=/()</DestinationUrl>\n" +
                "\t\t\t\t\t\t\t<DisplayUrl>fiat.com</DisplayUrl>\n" +
                "\t\t\t\t\t\t\t<Text>FIAT Palio The New Car</Text>\n" +
                "\t\t\t\t\t\t\t<Title>The Ad of Fiat</Title>\n" +
                "\t\t\t\t\t\t</TextAd>\n" +
                "\t\t\t\t\t\t<TextAd>\n" +
                "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                "\t\t\t\t\t\t\t<GxTextAdId>15669</GxTextAdId>\n" +
                "\t\t\t\t\t\t\t<BingTextAdId>0</BingTextAdId>\n" +
                "\t\t\t\t\t\t\t<Status>E</Status>\n" +
                "\t\t\t\t\t\t\t<Type>Text</Type>\n" +
                "\t\t\t\t\t\t\t<DestinationUrl>http://www.alos.com?l2tadgroupid=2262</DestinationUrl>\n" +
                "\t\t\t\t\t\t\t<DisplayUrl>www.aslo.com</DisplayUrl>\n" +
                "\t\t\t\t\t\t\t<Text>With funny des criptionseins</Text>\n" +
                "\t\t\t\t\t\t\t<Title>Other Thing</Title>\n" +
                "\t\t\t\t\t\t</TextAd>\n" +
                "\t\t\t\t\t</TextAdCollection>\n" +
                "\t\t\t\t</AdCollection>\n" +
                "\t\t\t</AdsAdGroupRequest>\n" +
                "\t\t</AdsAdGroupRequestCollection>\n" +
                "\t</Bing_AdsRequest>\n" +
                "</Bing_AdsRequestCollection>";

        AdManager resource = new AdManager();
        System.out.println("Consuming AddAds.....");
        String userName = testUtil.userName;
        String password = testUtil.password;
        String developerToken = testUtil.developerToken;
        long customerId = testUtil.customerId;
        long customerAccountId = testUtil.customerIdTest;
        String applicationId = testUtil.applicationId;
        String result = resource.addAds(customerAccountId, getAds(9));
        System.out.println("Result:\n" + result);
    }


    private static String getAds(int startNum){
        TestUtil testUtil = new TestUtil();

        String adsRequestsXML = "<Bing_AdsRequestCollection xmlns=\"L2TMediaDev_L2T1.51\">\n" +
                "\t<Bing_AdsRequest xmlns=\"L2TMediaDev_L2T1.51\">\n" +
                "\t\t<GxCampaignId>699</GxCampaignId>\n" +
                "\t\t<BingCampaignId>" + testUtil.campaignIdEmiliano + "</BingCampaignId>\n" +
                "\t\t<AdsAdGroupRequestCollection>\n" +
                "\t\t\t<AdsAdGroupRequest>\n" +
                "\t\t\t\t<GxAdGroupId>2262</GxAdGroupId>\n" +
                "\t\t\t\t<BingAdGroupId>" + testUtil.adGroupEmiliano + "</BingAdGroupId>\n" +
                "\t\t\t\t<AdCollection>\n" +
                "\t\t\t\t\t<TextAdCollection>\n" +
                "\t\t\t\t\t\t<TextAd>\n" +
                "\t\t\t\t\t\t\t<EditorialStatus/>\n" +
                "\t\t\t\t\t\t\t<GxTextAdId>15666</GxTextAdId>\n" +
                "\t\t\t\t\t\t\t<BingTextAdId>0</BingTextAdId>\n" +
                "\t\t\t\t\t\t\t<Status>E</Status>\n" +
                "\t\t\t\t\t\t\t<Type>Text</Type>\n" +
                "\t\t\t\t\t\t\t<DestinationUrl>?)(=/()</DestinationUrl>\n" +
                "\t\t\t\t\t\t\t<DisplayUrl>fiat.com</DisplayUrl>\n" +
                "\t\t\t\t\t\t\t<Text>FIAT Palio The New Car</Text>\n" +
                "\t\t\t\t\t\t\t<Title> The Ad of test Emiliano #" + startNum +  "</Title>\n" +
                "\t\t\t\t\t\t</TextAd>\n" +
                "\t\t\t\t\t\t<TextAd>\n" +
                "\t\t\t\t\t\t\t<GxTextAdId>15669</GxTextAdId>\n" +
                "\t\t\t\t\t\t\t<BingTextAdId>0</BingTextAdId>\n" +
                "\t\t\t\t\t\t\t<Status>E</Status>\n" +
                "\t\t\t\t\t\t\t<Type>Text</Type>\n" +
                "\t\t\t\t\t\t\t<DestinationUrl>http://www.alos.com?l2tadgroupid=2262</DestinationUrl>\n" +
                "\t\t\t\t\t\t\t<DisplayUrl>www.aslo.com</DisplayUrl>\n" +
                "\t\t\t\t\t\t\t<Text>Test Emiliano #" + (startNum + 1) +  "</Text>\n" +
                "\t\t\t\t\t\t\t<Title>Test Emiliano #" + (startNum + 1) +  "</Title>\n" +
                "\t\t\t\t\t\t</TextAd>\n" +
                "\t\t\t\t\t</TextAdCollection>\n" +
                "\t\t\t\t</AdCollection>\n" +
                "\t\t\t</AdsAdGroupRequest>\n" +
                "\t\t</AdsAdGroupRequestCollection>\n" +
                "\t</Bing_AdsRequest>\n" +
                "</Bing_AdsRequestCollection>";

        return adsRequestsXML;
    }
}
